﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UploadFile.ascx.cs" Inherits="admin_webparts_Plug_ins_Files_UploadFile" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %>

<div class="tip">
    <h1><%=LanguageUtility.GetLanguageText("UPLOAD_FILE", Session)%></h1>
    <table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-top: 20px;">
        <tr>
            <td align="left">
                <a class="path" href="?type=page&name=files&file=%2f"><%=NTTHAO.CommonWeb.WebGlobal.GetSite(System.Web.HttpContext.Current.Session).SiteID%></a> 
                <%
                    string[] parents = this._CurrentPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                    string path = "/";
                    for(int i = 0; i < parents.Length; i++)
                    {
                        string dir = parents[i];
                        path += dir + "/";
                %>
                /&nbsp;<a class="path" href="?type=page&name=files&file=<%=Server.UrlEncode(path) %>"><%=dir%></a>
                <%} %>
            </td>
        </tr>
    </table>
</div>
<%if(this._Message != string.Empty) { %>
<div class="tip tip_highlight">
    <span class="b">Message:&nbsp;</span><span class="red"><%=this._Message %></span>
</div>
<%} %>
<form id="frm" runat="server">
<table cellspacing="0" cellpadding="0" border="1" class="grid" style="margin: 10px auto;">
    <tr class="even" style="<%=Constant.ADD_LAYER_MASK ? "" : "display: none;"%>">
        <td align="right">Đính kèm logo:</td>
        <td><asp:CheckBox ID="chkLayerMask" Text="Đính kèm logo (đối với file ảnh *.jpg)" runat="server" /></td>
    </tr>
    <tr class="odd" id="row0">
        <td align="right" width="150px;" rowspan="11" style="background-color: #fff; border-bottom-width: 1px;"><%=LanguageUtility.GetLanguageText("SELECT_FILE", Session)%>:</td>
        <td><asp:FileUpload ID="fuFile1" runat="server" onchange="onChange(this, 1);" /><a id="linkMore1" class="moref path" href="#" onclick="moreFile(this, 1);return false;"><%=LanguageUtility.GetLanguageText("MORE_FILE_", Session)%></a></td>
    </tr>
    <tr class="even" id="row1" style="display: none;">
        <td><asp:FileUpload ID="fuFile2" runat="server" onchange="onChange(this, 2);" /><a id="linkMore2" class="moref path" href="#" onclick="moreFile(this, 2);return false;"><%=LanguageUtility.GetLanguageText("MORE_FILE_", Session)%></a></td>
    </tr>
    <tr class="odd" id="row2" style="display: none;">
        <td><asp:FileUpload ID="fuFile3" runat="server" onchange="onChange(this, 3);" /><a id="linkMore3" class="moref path" href="#" onclick="moreFile(this, 3);return false;"><%=LanguageUtility.GetLanguageText("MORE_FILE_", Session)%></a></td>
    </tr>
    <tr class="even" id="row3" style="display: none;">
        <td><asp:FileUpload ID="fuFile4" runat="server" onchange="onChange(this, 4);" /><a id="linkMore4" class="moref path" href="#" onclick="moreFile(this, 4);return false;"><%=LanguageUtility.GetLanguageText("MORE_FILE_", Session)%></a></td>
    </tr>
    <tr class="odd" id="row4" style="display: none;">
        <td><asp:FileUpload ID="fuFile5" runat="server" onchange="onChange(this, 5);" /><a id="linkMore5" class="moref path" href="#" onclick="moreFile(this, 5);return false;"><%=LanguageUtility.GetLanguageText("MORE_FILE_", Session)%></a></td>
    </tr>
    <tr class="even" id="row5" style="display: none;">
        <td><asp:FileUpload ID="fuFile6" runat="server" onchange="onChange(this, 6);" /><a id="linkMore6" class="moref path" href="#" onclick="moreFile(this, 6);return false;"><%=LanguageUtility.GetLanguageText("MORE_FILE_", Session)%></a></td>
    </tr>
    <tr class="odd" id="row6" style="display: none;">
        <td><asp:FileUpload ID="fuFile7" runat="server" onchange="onChange(this, 7);" /><a id="linkMore7" class="moref path" href="#" onclick="moreFile(this, 7);return false;"><%=LanguageUtility.GetLanguageText("MORE_FILE_", Session)%></a></td>
    </tr>
    <tr class="even" id="row7" style="display: none;">
        <td><asp:FileUpload ID="fuFile8" runat="server" onchange="onChange(this, 8);" /><a id="linkMore8" class="moref path" href="#" onclick="moreFile(this, 8);return false;"><%=LanguageUtility.GetLanguageText("MORE_FILE_", Session)%></a></td>
    </tr>
    <tr class="odd" id="row8" style="display: none;">
        <td><asp:FileUpload ID="fuFile9" runat="server" onchange="onChange(this, 9);" /><a id="linkMore9" class="moref path" href="#" onclick="moreFile(this, 9);return false;"><%=LanguageUtility.GetLanguageText("MORE_FILE_", Session)%></a></td>
    </tr>
    <tr class="even" id="row9" style="display: none;">
        <td><asp:FileUpload ID="fuFile10" runat="server" /></td>
    </tr>
</table>
<div class="tip tip_highlight">
    <span class="b"><%=LanguageUtility.GetLanguageText("WARNING", Session)%>:&nbsp;</span><span class="red"><%=LanguageUtility.GetLanguageText("REPLACE_FILE_WARNING", Session)%></span>
</div>
<p>
    <span id="spSave1" class="yui-button yui-link-button yuibtn yuibtn-icon btnupload"><span class="first-child"><asp:Button ID="btnSave1" runat="server" OnClick="btnSave_Click" Text="Save" /></span></span>
    <span id="spCancel1" class="yui-button yui-link-button yuibtn yuibtn-icon btncancel"><span class="first-child"><a href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath) %>" tabindex="0"><%=LanguageUtility.GetLanguageText("CANCEL", Session)%></a></span></span>
</p>
</form>
<style type="text/css">
    .moref { padding-left: 20px; }
    #spCancel1, #spSave1, #spCancel2, #spSave2 {font-size:1.1em; font-weight: bold; }
    #spCancel1 button, #spSave1 button, #spCancel2 button, #spSave2 button { font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: bold; }
</style>
<script type="text/javascript"> 
YAHOO.util.Event.onContentReady("spCancel1", function () {
    var spCancel1 = new YAHOO.widget.Button("spCancel1");
});
YAHOO.util.Event.onContentReady("spSave1", function () {
    var spSave = new YAHOO.widget.Button("spSave1");
});

function onChange(fuFile, index) {
    if (fuFile.files != null && fuFile.files.length > 0) {
        moreFile(document.getElementById('linkMore' + index), index);
    }
}

function moreFile(o, rowID) {
    var oFile = document.getElementById('<%=fuFile1.ClientID.TrimEnd('1') %>' + rowID);
    if (oFile.value == '') {
        alert('<%=LanguageUtility.GetLanguageText("SELECT_FILE_UPLOAD", Session)%>');
        return;
    }
    o.style.display = 'none';
    document.getElementById('row' + rowID).style.display = '';
}
</script>
